home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- // Copyright (C) 1997-1999 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- // Creation Date: June 30 1998
- //
- //<doc>
- //<name pointMatrixMult>
- //<owner "Alias|Wavefront Unsupported">
- //
- //<synopsis>
- // float[] pointMatrixMult ( float $point[], float $matrix[] )
- //
- //<description>
- // This script returns the multiplication of a point and a
- // matrix as an array of 3 doubles:
- //<pre>
- // vector * matrix = result
- //</pre>
- //<P>
- // <b>Note:</b> The matrix is assumed to be a single dimension
- // array of 16 elements.
- //<BR>
- // <b>Remember:</b> That the arrays are 0-based.
- // e.g. [1][0] is matrix[4] element
- //
- //<flags>
- // float $point[] Co-ordinates of the point.
- // float $matrix[] The matrix to be used.
- //
- //<returns>
- // float[] : Result as an array of 3 doubles.
- //
- //</doc>
- //
-
- global proc float[] pointMatrixMult( float $point[], float $matrix[] )
- //
- // Description:
- // Multiplies a point by a matrix and returns the result.
- //
- {
- float $result[];
-
- $result[0] = 0.0;
- $result[1] = 0.0;
- $result[2] = 0.0;
-
- if ( size($point) != 3 || size($matrix) != 16 )
- {
- warning("Point must be an array of 3 doubles and matrix must be an array of 16 doubles.");
- return $result;
- }
-
- // create the node that will do the actual computation
- //
- string $multNode;
- if ( catch($multNode = `createNode pointMatrixMult`) )
- {
- warning("Could not create pointMatrixMult node.");
- return $result;
- }
-
- // set the matrix and point inputs to the node
- //
- setAttr ($multNode+".vectorMultiply") true;
- setAttr ($multNode+".inPoint") -type "double3" $point[0] $point[1] $point[2];
- setAttr ($multNode+".inMatrix") -type "matrix" $matrix[0] $matrix[1] $matrix[2] $matrix[3] $matrix[4] $matrix[5] $matrix[6] $matrix[7] $matrix[8] $matrix[9] $matrix[10] $matrix[11] $matrix[12] $matrix[13] $matrix[14] $matrix[15];
-
- // get the result and delete the node since it is no longer required
- //
- $result = `getAttr ($multNode+".output")`;
- delete $multNode;
-
- return $result;
- }
-